class Wacther {
    constructor(vm, key, cb) {
        this.vm = vm;
        this.key = key;
        this.cb = cb
        // 把watcher 对象记录在Dep类的静态属性target
        Dep.target = this
        // 触发get方法，然后调用addSub方法
        this.oldValue = vm[key]
        Dep.target = null
    }
    // 更新视图
    update() {
        let newValue = this.vm[this.key]
        if (newValue === this.oldValue) {
            return
        }
        this.cb(newValue)
    }
}